﻿
#ifndef _DIB
#define _DIB

#include "../Public/windows.h"
#include "time.h"

typedef unsigned char BYTE;
#define BOOL bool

struct DibPOINT
{
    int x,y;
};

class CDibPoint
{
public:
    CDibPoint(){}
    CDibPoint(int x0,int y0);	
    int	x,y;
};


class CDibRect
{
public:
	int	left,top,right,bottom;

	CDibRect(){}
	CDibRect(int l,int t,int r,int b);	
	CDibRect(CDibRect& r);

	int	Width();
	int	Height();
	CDibPoint	CenterPoint();	
	CDibPoint	TopLeft();
	CDibPoint	BottomRight();
	void	OffsetRect(int x,int y);
	bool 	IntersectRect(CDibRect* pRect);
};






class CDIB
{
public:
	CDIB();
	~CDIB();

	void	CreateDIB(int width,int height,int bitcount);
	void	CreateDIB(CDIB* pDib,bool bCopy);
	void	CreateDIB(int width,int height,int bitcount,BYTE* pBits);
	void	DestroyDIB();
	void	ZeroDIB();
	BYTE*	GetPixelAddress(int x,int y);
	int		StorageWidth();
	int		GetBitSize();
	void	GetRect(CDibRect* pRect);
	bool	LoadDIB(char* filename);
	bool	SaveDIB(char* filename);
	DWORD	ReadPixel(double x,double y);
	void	WritePixel(int x,int y,DWORD c);
	int		Width();
	int		Height();							

	int	m_width;
	int	m_height;
	int	m_bitcount;
	bool	m_bOwnBits;

	BYTE*	m_pBits;
	BITMAPINFOHEADER*	m_pBMI;

	int	m_flag;
	int	m_order;

	int	m_nCardNo;
	double	m_capTime;
};


#endif

